//
//  ViewController.m
//  04-HomeWork
//
//  Created by dllo on 16/7/19.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (nonatomic, strong) UIImageView *jieLunImageView;
@property (nonatomic, strong) UILabel *rightLabel;
@property (nonatomic, strong) UILabel *leftLabel;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
  //背景图片
    UIImageView *backGoroundImageView = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    backGoroundImageView.image = [UIImage imageNamed:@"welcome_2"];
    [self.view addSubview:backGoroundImageView];
    //下拉按钮
    UIButton *putdownButton = [[UIButton alloc] initWithFrame:CGRectMake(10, 20, 40, 40)];
    [putdownButton setImage:[UIImage imageNamed:@"player_btn_putDown"] forState:UIControlStateNormal];
    [self.view addSubview:putdownButton];
   //MusicName
    UILabel *musicLabel = [[UILabel alloc] initWithFrame:CGRectMake(160, 20, 80, 50)];
    musicLabel.text = @"稻香";
    musicLabel.textColor = [UIColor whiteColor];
    musicLabel.font = [UIFont systemFontOfSize:25];
    [self.view addSubview:musicLabel];
   //三个圆点
    UIButton *threeRoundDotButton = [[UIButton alloc] initWithFrame:CGRectMake(300, 25, 40, 40)];
    [threeRoundDotButton setImage:[UIImage imageNamed:@"player_btn_threeRound dot"] forState:UIControlStateNormal];
    [self.view addSubview:threeRoundDotButton];
  //MusicerName
    UILabel *musicerNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(130, 50, 150, 50)];
    musicerNameLabel.text = @"－  周杰伦  －";
    musicerNameLabel.textColor = [UIColor whiteColor];
    musicerNameLabel.font = [UIFont systemFontOfSize:20];
    [self.view addSubview:musicerNameLabel];
  //流畅
    UIImageView *fluencyImageView = [[UIImageView alloc] initWithFrame:CGRectMake(40, 90, 60, 25)];
    fluencyImageView.image = [UIImage imageNamed:@"player_btn_normal"];
    [self.view addSubview:fluencyImageView];
  //独家
    UIImageView *oneselfImageView = [[UIImageView alloc] initWithFrame:CGRectMake(115, 90, 60, 25)];
    oneselfImageView.image = [UIImage imageNamed:@"player_btn_copyright"];
    [self.view addSubview:oneselfImageView];
  //MV
    UIImageView *mvImageView = [[UIImageView alloc] initWithFrame:CGRectMake(195, 90, 60, 25)];
    mvImageView.image = [UIImage imageNamed:@"player_btn_mv"];
    [self.view addSubview:mvImageView];
  // dts
    UIImageView *dtsImageView = [[UIImageView alloc] initWithFrame:CGRectMake(270, 90, 60, 25)];
    dtsImageView.image = [UIImage imageNamed:@"player_btn_dts_on"];
    [self.view addSubview:dtsImageView];
    
  //图片组
    UILabel *jielunLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, 130, 310, 320)];
    jielunLabel.userInteractionEnabled = YES;
    jielunLabel.layer.cornerRadius = 150;
    jielunLabel.clipsToBounds = YES;
    jielunLabel.backgroundColor = [UIColor redColor];
    [self.view addSubview:jielunLabel];
    
    self.jieLunImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 310, 320)];
    self.jieLunImageView.userInteractionEnabled = YES;
    self.jieLunImageView.clipsToBounds = YES;
    self.jieLunImageView.image = [UIImage imageNamed:@"杰伦－01"];
    [jielunLabel addSubview:self.jieLunImageView];
    UILabel *musicName = [[UILabel alloc] initWithFrame:CGRectMake(130, 420, 310, 80)];
    musicName.text = @"稻香 － 周杰伦";
    musicName.textColor = [UIColor whiteColor];
    
    [self.view addSubview:musicName];
  // UIPageControl
    UIPageControl *pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(30, 450, 310, 50)];
    pageControl.numberOfPages = 3;
    [pageControl addTarget:self action:@selector(pageControlAction:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:pageControl];
  //UISlider
    UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(70, 500, self.view.frame.size.width - 160, 50)];
    [slider setThumbImage:[UIImage imageNamed:@"player_slider_playback_thumb"] forState:UIControlStateNormal];
    [slider setMinimumTrackImage:[UIImage imageNamed:@"player_slider_playback_left"] forState:UIControlStateNormal];
    
    [self.view addSubview:slider];
    self.leftLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 500, 50, 50)];
    self.leftLabel.text = @"00:00";
    self.leftLabel.textColor = [UIColor whiteColor];
    self.leftLabel.textAlignment = NSTextAlignmentCenter;
//    self.leftLabel.backgroundColor = [UIColor redColor];
    [self.view addSubview:self.leftLabel];
    self.rightLabel = [[UILabel alloc] initWithFrame:CGRectMake(300, 500, 50, 50)];
    self.rightLabel.text = @"03:43";
    self.rightLabel.textColor = [UIColor whiteColor];
    self.rightLabel.textAlignment = NSTextAlignmentCenter;

//    self.rightLabel.backgroundColor = [UIColor redColor];
    [self.view addSubview:self.rightLabel];
  //  button
    UIButton *playButton = [[UIButton alloc] initWithFrame:CGRectMake(150, 530, 80, 80)];
    playButton.tag = 1000;
    [playButton setImage:[UIImage imageNamed:@"player_btn_play_normal"] forState:UIControlStateNormal];
    [playButton addTarget:self action:@selector(playButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:playButton];
    
    UIButton *play_left_button = [[UIButton alloc] initWithFrame:CGRectMake(60, 530, 80, 80)];
    [play_left_button setImage:[UIImage imageNamed:@"player_btn_pre_normal"] forState:UIControlStateNormal];
    [self.view addSubview:play_left_button];
    UIButton *play_right_button = [[UIButton alloc] initWithFrame:CGRectMake(240, 530, 80, 80)];
    [play_right_button setImage:[UIImage imageNamed:@"player_btn_next_normal"] forState:UIControlStateNormal];
    [self.view addSubview:play_right_button];
    
//    bottom
    UIButton *loveButton = [[UIButton alloc] initWithFrame:CGRectMake(10, 590, 100, 100)];
    [loveButton setImage:[UIImage imageNamed:@"player_btn_favorited_normal"] forState:UIControlStateNormal];
    [self.view addSubview:loveButton];
    
    UIButton *cycleButton = [[UIButton alloc] initWithFrame:CGRectMake(80, 590, 100, 100)];
    [cycleButton setImage:[UIImage imageNamed:@"player_btn_repeat_highlight"] forState:UIControlStateNormal];
    [self.view addSubview:cycleButton];
    UIButton *downLodeButton = [[UIButton alloc] initWithFrame:CGRectMake(140, 590, 100, 100)];
    [downLodeButton setImage:[UIImage imageNamed:@"player_btn_download_pay_normal"] forState:UIControlStateNormal];
    [self.view addSubview:downLodeButton];
    UIButton *shareButton = [[UIButton alloc] initWithFrame:CGRectMake(200, 590, 100, 100)];
    [shareButton setImage:[UIImage imageNamed: @"player_btn_share_highlight"] forState:UIControlStateNormal];
    [self.view addSubview:shareButton];
    UIButton *moreMusicButton = [[UIButton alloc] initWithFrame:CGRectMake(270, 590, 100, 100)];
    [moreMusicButton setImage:[UIImage imageNamed:@"player_btn_playlist_highlight"] forState:UIControlStateNormal];
    [self.view addSubview:moreMusicButton];
    
}
- (void)pageControlAction:(UIPageControl *)pageControl {
    NSArray *imageArray = @[@"杰伦－01",@"杰伦－02",@"杰伦－03"];
    NSInteger randomNumber = arc4random() % (2 - 0 + 1);
    NSString *imageName = [imageArray objectAtIndex:randomNumber];
    self.jieLunImageView.image = [UIImage imageNamed:imageName];
}
- (void)playButtonClicked:(UIButton *)playButton {
    UIButton *button = [self.view viewWithTag:1000];
  // 先移除
    [button removeTarget:self action:@selector(playButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
    [button setImage:[UIImage imageNamed:@"player_btn_pause_normal"] forState:UIControlStateNormal];
  // 在添加
    [button addTarget:self action:@selector(stopButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
}
- (void)stopButtonClicked:(UIButton *)stopButton {
    UIButton *button = [self.view viewWithTag:1000];
    // 先移除
    [button removeTarget:self action:@selector(stopButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
    [button setImage:[UIImage imageNamed:@"player_btn_play_normal"] forState:UIControlStateNormal];
    // 在添加
    [button addTarget:self action:@selector(playButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
